

// 获取商品详情 main
window.onload = function () {
    ajax({
        url: "http://chst.vip:1234/api/getinlanddiscount",
    })
        .then(res => {
            let main = document.querySelector('main');
            let html = '';
            res.result.forEach(item => {
                html += `
         <div id="product" productid=${item.productId}>
            <section id="img">${item.productImg}</section>
            <section id="content">
                <a id="title" href="shangpinxiangqing.html?productId=${item.productId}">
                        <i>${item.productName}</i>
                        <p>${item.productPrice}</p>

                    <div id="mall">
                        <i>${item.productFrom} | ${item.productTime}</i>
                    </div>
                    <div id="bigimg"></div>
                </a>
            </section>
               </div>
        `
            });
            main.innerHTML = html;
            let product = document.querySelector("#product");
            [...main.children].forEach(product => {
                product.onclick = function () {
                    let productid = product.getAttribute('productid');
                    location.href = `guoneizhekoushangpinxiangqing.html?productid=${productid}`
                }
            })
        })
}


